﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace QuanLyThuoc
{
    class ChiTietHoaDon
    {
        string maHoaDon;
        string maThuoc;
        int soLuong;
        
        public string MaHoaDon
        {
            get { return maHoaDon; }
            set { maHoaDon = value; }
        }
        public string MaThuoc
        {
            get { return maThuoc; }
            set { maThuoc = value; }
        }
        public int SoLuong
        {
            get { return soLuong; }
            set { soLuong = value; }
        }

        public ChiTietHoaDon()
        { }

        public ChiTietHoaDon(string maHoaDon, string maThuoc, int soLuong)
        {
            this.maHoaDon = maHoaDon;
            this.maThuoc = maThuoc;
            this.soLuong = soLuong;
        }

        public void NhapCTHD()
        {
            Console.Write("\nNhap ma hoa don: ");
            maHoaDon = Console.ReadLine();
            Console.Write("\nNhap ma Thuoc: ");
            maThuoc = Console.ReadLine();
            Console.Write("\nNhap so luong thuoc: ");
            soLuong = int.Parse(Console.ReadLine());
        }

        public void XuatCTHD()
        {
            Console.Write("\n\t" + maHoaDon);
            Thuoc thuoc = DanhSachThuoc.TimTheoMa(maThuoc);
            //DanhSachThuoc thuoc = new DanhSachThuoc();
            Console.Write(thuoc.TenThuoc.PadLeft(12));
            Console.Write(soLuong.ToString().PadLeft(10));
        }

        public void ghiFile()
        {
            FileStream file = new FileStream("DSChitietHD.txt", FileMode.Append);
            BinaryWriter br = new BinaryWriter(file);
            br.Write(maHoaDon);
            br.Write(maThuoc);
            br.Write(soLuong.ToString());
            br.Close();
            file.Close();
        }
    }
}
